package py.org.atom.seam.util;

import java.util.Locale;
import java.util.PropertyResourceBundle;

import org.jboss.seam.annotations.Name;

@Name("sys")
public class Sys {
	
	public static final String ID_COLNAME = "id";
	public static final int ID_MAXLEN=50;
	public static final int ID_MINLEN=5;
	public static final String PASSWORD_COLNAME="pwd";
	public static final int PASSWORD_MAXLEN=100;
	public static final int PASSWORD_MINLEN=5;
	public static final String STATUS_COLNAME="status";
	public static final String LDAP_COLNAME="ldap";
	
	public static final String INSERT_USER_COLUMN="insusr";
	public static final String UPDATE_USER_COLUMN="updusr";
	public static final String DISABLE_USER_COLUMN="disusr";

	public static final String INSERT_DATE_COLUMN="insdate";
	public static final String UPDATE_DATE_COLUMN="upddate";
	public static final String DISABLE_DATE_COLUMN="disdate";	
	
	
	public static final PropertyResourceBundle getResource(){
		
		PropertyResourceBundle prop = (PropertyResourceBundle) PropertyResourceBundle.getBundle("system", Locale.US);
		
		return prop;
	}
	
	public static final String property(String key){
		
		try{
			PropertyResourceBundle prop = getResource();
			String value = (String)prop.getString(key);
			if(value != null)
				return value;
		}catch(Exception e){
			return null;
		}		
		
		return null;
	}
	
	public static final int intProperty(String key){
		
		int out = -1;
		
		String sProp = property(key);
		if(sProp == null)
			return out;
		
		try{
			out = Integer.parseInt(sProp);
			return out;
		}catch(Exception e){
			return out;
		}
		
	}
	
}
